package jxls;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import model.Department;
import model.Employee;
import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

public class Test {

	public static void main(String[] args) throws ParsePropertyException, InvalidFormatException, IOException {

		String rootPath = System.getProperty("user.dir");
		String template = rootPath + "/template/template.xls";  
		String generate = rootPath + "/generate/generate.xls";  
  
		Department depIT = new Department("IT");

        Employee chief = new Employee("Derek", 35, 3000, 0.30);
        depIT.setChief(chief);
        Employee elsa = new Employee("Elsa", 28, 1500, 0.15);
        depIT.addEmployee(elsa);
        Employee oleg = new Employee("Oleg", 32, 2300, 0.25);
        depIT.addEmployee(oleg);
        Employee neil = new Employee("Neil", 34, 2500, 0.00);
        depIT.addEmployee(neil);
        Employee maria = new Employee("Maria", 34, 1700, 0.15);
        depIT.addEmployee(maria);
        Employee john = new Employee("John", 35, 2800, 0.20);
        depIT.addEmployee(john);
        
        Department depHR = new Department("HR");

        Employee natali = new Employee("Natali", 25, 1200, 0.1);
        depHR.addEmployee( natali );
        Employee helen = new Employee("Helen", 27, 1100, 0.20);
        depHR.addEmployee(helen);
        Employee olga = new Employee("Olga", 24, 1150, 0.00);
        depHR.addEmployee(olga);
		
        Map<String, Object> beanParams = new HashMap<String, Object>();  
        beanParams.put("list", depIT);  
        beanParams.put("list2", depHR);  
        beanParams.put("name", "涂有");  
        XLSTransformer former = new XLSTransformer();  
//        Workbook wb = former.transformXLS(new FileInputStream(template), beanParams);
        former.transformXLS(template, beanParams, generate);
	}

}
